<template>
	<view class="mainpadding">
		<view class="flexright">
			<view class="xlvbtn" @click="tzfqhd">开具历史</view>
		</view>
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class=" xiahuaxian shangc1" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="shilitu">
					<image :src="item.orderinfo.image_text" mode=""></image>
				</view>
				<view class="flexcolumnbet" style="width: 69%;height: 160rpx;">
					<view class="flexbetween" style="width: 100%;">
						<view class="strongtext xiaohui nofonweight margin_right2 ">{{item.createtime_text}}</view>
						<view class="xiaohui smalltext" v-if="item.status==1">未开票</view>
						<view class="xiaohuang smalltext" v-if="item.status==2">开票中</view>
						<view class="xiaolv smalltext" v-if="item.status==3">已开票</view>
					</view>
					<view class="sanshier xiaohei fonweight yhxk">{{item.orderinfo.name}}</view>
					<view class="flexbetween" style="width: 100%;">
						<view class="sanshier xiaohong fonweight">￥{{item.price}}</view>
						<view class="lvbtn" v-if="item.status==1" @click="tzfpsq(item.id)">开具发票</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit
				}
				let url = '/api/Fpqdcl/index'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转发票申请
			tzfpsq(id) {
				uni.navigateTo({
					url: '/pages_mypage/fapiaosq?id='+id
				})
			},
			// 跳转开具历史
			tzfqhd() {
				uni.navigateTo({
					url: '/pages_mypage/kaijulishi'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.xlvbtn {
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		width: 116rpx;
		height: 40rpx;
		background: #1BA95B;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.shilitu {
		width: 200rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.touxiang {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.shangc1 {
		padding-top: 30rpx;
	}

	.shangc1:first-child {
		padding-top: 0rpx;
	}
</style>